|
|
|
|
|
|
|
Working with the Err Object |
|
|
|
|
|
|
|
|
Visual Basic 5 has a built-in object called the Err object. This object holds all the information about the most recent error that occurred within the running application space. |
|
|
|
|
| |
|
|
|
|
There is a bit of confusion regarding the Err keyword in Visual Basic. Visual Basic 5 still supports the outdated Err and Error functions, but we do not advise you to use them in your programs. In some rare cases, the values reported by the Err and Error functions are not the same as those reported by the Err object. Throughout this book, when we mention "Err" we are referring to the Err object, not the Err function. |
|
|
|
|
|
|
|
|
|
|
The Err object has several important properties. Table 14.1 shows these properties and explains their use. |
|
|
|
|
| Table 14.1. The properties of the Err object. | | Property | Type | Value | | Number | Long | The actual internal error number returned by Visual Basic. | | Source | String | Name of the current Visual Basic file in which the error occurred. This could be an EXE, DLL, or OCX file. | | Description | String | A string corresponding to the internal error number returned in the Number property, if this string exists. If the string doesn't exist, Description contains ''Application-defined or object-defined error." | | HelpFile | String | The fully qualified drive, path, and filename of the Help file. This help file can be called to support the reported errors. | | HelpContext | Long | The Help file context (topic) ID in the help file indicated by the HelpFile property. | | LastDLLError | Long | The error code for the last call to a dynamic-link library (DLL). This is available only on 32-bit Microsoft platforms. |
|
|
|